package objects;

import materials.Material;
import math.Vector3D;
import render.Ray;
import render.TraceResult;

public class Plane extends RenderObject {

    protected Vector3D normal;

    public Plane( Vector3D position , Vector3D normal , Material material ) {
	super( position, material );
	this.normal = normal;
	this.normal.Normalize();
    }

    @Override
    public TraceResult trace( Ray ray ) {

	double d = position.dot( normal );
	double t = (d - ray.getPosition().dot( normal )) / (ray.getDirection().dot( normal ));
	if ( normal.dot( ray.getDirection() ) < 0 )
	    return new TraceResult( true , t );
	else
	    return new TraceResult( false , 0 );
    }

    public Vector3D getNormal( Vector3D intersect ) {
	return normal;

    }

}
